package model;

import model.MemoryBlock;

/**
 * @Create Harlantown
 * @Description
 * @create 2022-12-27 下午 5:49
 */
public class PageTableEntry {
    // 页表项在当前页表的编号
    private int pageNumber;
    // 页表项对应的内存块编号
    private int physicalBlockNumber;
    // 该项是否已经加载到内存中
    private boolean availableInMemory;
    // 用于置换页面的时间参数
    private long LRU;
    // 该块是否修改
    private boolean isModified;
    // 该页表项指向的磁盘地址
    private int diskAddress;
    // 该页表项在文件中的逻辑编号
    private int logicNum;

    public PageTableEntry() {
    }

    public PageTableEntry(MemoryBlock block, int id, int diskAddr) {
        this.pageNumber = id;
        this.physicalBlockNumber = block.getPhysicalNumber();
        this.availableInMemory = false;
        this.LRU = System.currentTimeMillis();
        this.isModified = false;
        this.diskAddress = diskAddr;
        this.logicNum = -1;
    }

    public PageTableEntry(int id, int diskAddr) {
        this.pageNumber = id;
        this.physicalBlockNumber = -1;
        this.availableInMemory = false;
        this.LRU = -1;
        this.isModified = false;
        this.diskAddress = diskAddr;
    }
    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getPhysicalBlockNumber() {
        return physicalBlockNumber;
    }

    public void setPhysicalBlockNumber(int physicalBlockNumber) {
        this.physicalBlockNumber = physicalBlockNumber;
    }

    public boolean isAvailableInMemory() {
        return availableInMemory;
    }

    public void setAvailableInMemory(boolean availableInMemory) {
        this.availableInMemory = availableInMemory;
    }

    public long getLRU() {
        return LRU;
    }

    public void setLRU(long LRU) {
        this.LRU = LRU;
    }

    public boolean isModified() {
        return isModified;
    }

    public void setModified(boolean modified) {
        isModified = modified;
    }

    public int getDiskAddress() {
        return diskAddress;
    }

    public void setDiskAddress(int diskAddress) {
        this.diskAddress = diskAddress;
    }

    public int getLogicNum() {
        return logicNum;
    }

    public void setLogicNum(int logicNum) {
        this.logicNum = logicNum;
    }
}
